package lab02.test35;

import java.util.Scanner;

/**
 * Created by 123 on 2017/12/29.
 */
public class Test35 {
    public static void main(String[] args) {
        Student[] student = new Student[5];
//输入5位学生的信息：
        String level;
        int count = 0;
        while (count < 5) {
            System.out.println("请输入学生学历：");
            Scanner scanner = new Scanner(System.in);
            level = scanner.nextLine();
            if (level.equals("本科生")) {
                for (int i = 0; i < 3; i++) {
                   student[i] = new Student();
                    student[i].course = new double[3];
                    student[i].student_type = level;
                    System.out.println("请输入本科生名字：");
                    Scanner scanner1 = new Scanner(System.in);
                    student[i].name = scanner1.nextLine();
                    for (int j = 0; j < student[i].course.length; j++) {
                        System.out.println("请输入本科生成绩：");
                        Scanner scanner2 = new Scanner(System.in);
                        student[i].course[j] = scanner2.nextDouble();
                    }
                    count++;
                }
            } else if (level.equals("研究生")) {
                for (int i = 3; i < 5; i++) {
                    student[i] = new PostGraduate();
                    student[i].course = new double[3];
                    student[i].student_type = level;
                    System.out.println("请输入研究生名字：");
                    Scanner scanner1 = new Scanner(System.in);
                    student[i].name = scanner1.nextLine();
                    for (int j = 0; j < student[i].course.length; j++) {
                        System.out.println("请输入研究生成绩：");
                        Scanner scanner2 = new Scanner(System.in);
                        student[i].course[j] = scanner2.nextDouble();
                    }
                    count++;
                }
            } else System.out.println("请重新输入！");

        }
        //输出详细信息：
        System.out.println("姓名\t" + "类型\t" + "成绩");
        for (int i = 0; i < student.length; i++) {
            System.out.println(student[i].name + "\t" + student[i].student_type + "\t" + student[i].avergage(student[i].course));
        }
    }
}

